import 'package:flutter/material.dart';
import '../common/common_ui.dart';
import '../common/http.dart';


/* Dio使用 */
class DioPage extends StatefulWidget {
  @override
  _DioPageState createState() => _DioPageState();
}
    String _text = "aaa";
class _DioPageState extends State<DioPage> {

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(
        title: Text('Dio网络请求'),
        elevation: 0.0,
      ),
      body: Container(
        child: Column(
          children: <Widget>[
            RaisedButton(
              child: Text("Request"),
              onPressed: () {
                dio.get<String>("http://httpbin.org/get").then((r) {
                  setState(() {
                     _text = r.data;
                    print(r.data);
                   
                  });
                }).catchError(print);
              },
            ),
           Expanded(
            child: SingleChildScrollView(
              child: Text(_text),
            ),
           )
          ],
        )
      ),  
    );
  }
  
}
